package com.myproject.reflect;

import java.lang.reflect.Constructor;

public class Cat {

    private String name;

    public Cat(String name) {
        this.name = name;
    }

    public void sayHello(){
        System.out.println("my name is "+name);
    }

    public static void main(String[] args) throws Exception {
        Class c = Cat.class;
        Constructor[] constructors = c.getConstructors();
        System.out.println(constructors.length);
        //Cat cat = (Cat) c.newInstance();
        Cat cat = (Cat) constructors[0].newInstance("tom");
        cat.sayHello();
    }
}
